package com.assessment.util;

import java.io.File;  
import java.io.FileInputStream;  
import java.io.IOException;  
import java.util.ArrayList;
import java.util.List;


import org.apache.poi.hssf.usermodel.HSSFCell;  
import org.apache.poi.hssf.usermodel.HSSFRow;  
import org.apache.poi.hssf.usermodel.HSSFSheet;  
import org.apache.poi.hssf.usermodel.HSSFWorkbook;  

import com.assessment.entity.Comprehensive;
import com.assessment.entity.FirstPhase;

public class ImportComprehensive {
	

	public List<Comprehensive> importCom(String path) throws IOException{
		 FileInputStream inputStream = new FileInputStream(new File(path));  
	        //读取工作簿  
	        HSSFWorkbook workBook = new HSSFWorkbook(inputStream);  
	        //读取工作表  
	        HSSFSheet sheet = workBook.getSheetAt(1);  
	        List<Comprehensive> list=new ArrayList<Comprehensive>();
	        for(int i=3;i<=sheet.getLastRowNum();i++){
	        	 //读取行  
		        HSSFRow row = sheet.getRow(i);
		
		        //读取单元格
		        HSSFCell cell0 = row.getCell(0);
		        HSSFCell cell1 = row.getCell(47);
		        HSSFCell cell2 = row.getCell(48); 
		        HSSFCell cell3 = row.getCell(49); 
		        HSSFCell cell4 = row.getCell(50); 
		        HSSFCell cell5 = row.getCell(51); 
		        HSSFCell cell6 = row.getCell(52); 
		        HSSFCell cell7 = row.getCell(53); 
		        HSSFCell cell8 = row.getCell(54);

		      //设t置单元格类型	     
			    Comprehensive com= new Comprehensive();
			    com.setStaff_id(Integer.parseInt(cell0.getStringCellValue()));
		        if(cell1.toString()!=null&&!"".equals("好")){
		        	com.setResponsibility(1);
		        }else{
		        	com.setResponsibility(2);
		        }
		        if(cell2!=null&&!"".equals("好")){
		        	com.setInitiative(1);
		        }else{
		        	com.setInitiative(2);
		        }
		        if(cell3!=null&&!"".equals("好")){
		        	com.setCompressive(1);
		        }else{
		        	com.setCompressive(2);
		        }
		        if(cell4!=null&&!"".equals("好")){
		        	com.setTeamspirit(1);
		        }else{
		        	com.setTeamspirit(2);
		        }
		        if(cell5!=null&&!"".equals("好")){
		        	com.setLearn(1);
		        }else{
		        	com.setLearn(2);
		        }
		        if(cell6!=null&&!"".equals("好")){
		        	com.setCommunication(1);
		        }else{
		        	com.setCommunication(2);
		        }
		        if(cell8!=null&&!"".equals("好")){
		        	com.setViolations(1);
		        }else{
		        	com.setViolations(2);
		        }
		        if(cell7!=null){
		        	com.setEvaluation(cell7.getStringCellValue());
		        }
		     
		       
		        list.add(com);
	    
		       
	        }
	        
	        for(int i = 0 ; i < list.size() ; i++) {
	        	System.out.println(list.get(i));
	        	}
	        inputStream.close();  
	        workBook.close();//最后记得关闭工作簿  
		return list;
	}
	  
}